/**
 * Created by xuechao on 2016/8/30.
 */
var app = angular.module("app", ['ngResource']);
app.factory('Service', ['$resource', function ($resource) {
    return $resource('/GMS/:action', {
        action: '@action'
    }, {
        getMenus1: {
            method: 'GET',
            isArray: false
        },
        loadDefaultPage: {
            method: 'GET',
            isArray: false
        },
        getUserMonitorWarning: {
            method: 'GET',
            isArray: false
        }
    });
}]);
app.controller("myCtrl", function ($scope, Service, $timeout) {
    //加载菜单
    Service.getMenus1({
        action: 'findMenu'
    }, function (data) {
        $scope.records = data.data.menuVO;
    })
    //加载默认页面
    Service.loadDefaultPage({
        action: 'loadDefaultPage'
    }, function (data) {
        $scope.url = data.url;
    });
    //加载用户监控告警
    var getWarning = function () {
        Service.getUserMonitorWarning({
                action: 'getUserMonitorWarning'
            }, function (data) {
                if (data.state == 'SUCCESS') {
                    $scope.userMonitorWarningNum = data.data.userMonitorWarningNum[0]==0?null:data.data.userMonitorWarningNum[0];
                }
            }
        );
        $timeout(function () {
            getWarning();
        }, 5000)
    };
    getWarning();
});